<?php
namespace Plu\Library\Services\Platform\Room;

use Plu\Library\Services\ServiceBase,
    Plu\Library\Models\Platform\Rooms\Room as RoomModel,
    Plu\Library\Services\Redis\Room\RoomRedis;

class RoomsService extends ServiceBase {

    public function getRoomInfo($roomId) {
        if ($roomId > 0) {
            return RoomModel::getRoomInfo($roomId);
        } else {
            return [];
        }
    }

    public function getRoomInfoByDomain($domain) {
        $redis = new RoomRedis;
        $roomId = $redis->getRoomId($domain);

        if ($roomId) {
            return $this->getRoomInfo($roomId);
        } else {
            //尝试查询数据库
            return RoomModel::getRoomInfoByDomain($domain);
        }

        return [];
    }
}
